package com.ruoyi.feiyi.service.impl;

import java.util.Arrays;
import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.feiyi.domain.FyActivity;
import com.ruoyi.feiyi.service.IFyActivityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.feiyi.mapper.FyActivityUserMapper;
import com.ruoyi.feiyi.domain.FyActivityUser;
import com.ruoyi.feiyi.service.IFyActivityUserService;
import com.ruoyi.common.core.text.Convert;
import org.springframework.transaction.annotation.Transactional;

/**
 * 用户报名活动Service业务层处理
 * 
 * @author ruoyi
 * @date 2024-11-26
 */
@Service
public class FyActivityUserServiceImpl extends ServiceImpl<FyActivityUserMapper, FyActivityUser> implements IFyActivityUserService
{

    @Autowired
    private IFyActivityService iFyActivityService;
    /**
     * 查询用户报名活动
     * 
     * @param id 用户报名活动主键
     * @return 用户报名活动
     */
    @Override
    public FyActivityUser getInfoById(Long id)
    {
        return this.getById(id);
    }

    /**
     * 查询用户报名活动列表
     * 
     * @param fyActivityUser 用户报名活动
     * @return 用户报名活动
     */
    @Override
    public List<FyActivityUser> selectList(FyActivityUser fyActivityUser)
    {
        return baseMapper.selectList(fyActivityUser);
    }

    /**
     * 新增用户报名活动
     * 
     * @param vo
     * @return 结果
     */
    @Override
    @Transactional
    public int insertFyActivityUser(FyActivityUser vo)
    {
        vo.setCreateTime(DateUtils.getNowDate());
        this.save(vo);
        //修改活动报名人数
        iFyActivityService.updateSignNum(vo.getActivityId());
        return 1;
    }

    /**
     * 修改用户报名活动
     * 
     * @param fyActivityUser 用户报名活动
     * @return 结果
     */
    @Override
    public int updateFyActivityUser(FyActivityUser fyActivityUser)
    {
        fyActivityUser.setUpdateTime(DateUtils.getNowDate());
        this.updateById(fyActivityUser);
        return 1;
    }

    /**
     * 批量删除用户报名活动
     * 
     * @param ids 需要删除的用户报名活动主键
     * @return 结果
     */
    @Override
    public int deleteFyActivityUserByIds(String ids)
    {
        this.removeByIds(Arrays.asList(Convert.toStrArray(ids)));
        return 1;
    }

    /**
     * 删除用户报名活动信息
     * 
     * @param id 用户报名活动主键
     * @return 结果
     */
    @Override
    public int deleteFyActivityUserById(Long id)
    {
        this.removeById(id);
        return 1;
    }
}
